<?php 
$login = 'test'; 
$pass = 'test';

// Here is a extremely easy way to successfully logout. 
echo $realm = mt_rand( 1, 1000000000 );

if(($_SERVER['PHP_AUTH_PW']!= $pass || $_SERVER['PHP_AUTH_USER'] != $login)|| !$_SERVER['PHP_AUTH_USER']) 
{ 
    header('WWW-Authenticate: Basic realm="Test auth"');
    header('HTTP/1.0 401 Unauthorized'); 
    echo 'Auth failed'; 
    exit; 
}

if (isset($_GET['logout'])) {
	 header( 'WWW-Authenticate: Basic realm='.$realm ); 
}
